package com.pearlsoft.rms;

import java.util.ArrayList;
import java.util.List;

/**
 * 
 * @author rainshow
 * @Created 2012-5-14 上午09:32:42
 */

public class VappConfig {
    String name;
    String vdcName = "test";
    String orgName = "test";
    List<VmConfig> vmConfig;

    public VappConfig(String name) {
        this.name = name;
        this.vmConfig = new ArrayList<VmConfig>();
    }

    public void addVm(String vmName, String os, int cpuCount, int networkCount, int memSize, int diskSize, int version) {
        addVm(vmName, os, cpuCount, networkCount, memSize, diskSize, version, null);
    }

    public void addVm(String vmName, String os, int cpuCount, int networkCount, int memSize, int diskSize, int version,
            List<String> ip) {
        VmConfig config = new VmConfig(vmName, os, cpuCount, networkCount, memSize, diskSize, version);
        if (ip != null) {
            config.ipAddress.addAll(ip);
        }
        this.vmConfig.add(config);
    }

    public String getName() {
        return name;
    }

    public List<VmConfig> getVmConfig() {
        return vmConfig;
    }

    public String getVdcName() {
        return vdcName;
    }

    public void setVdcName(String vdcName) {
        this.vdcName = vdcName;
    }

    public String getOrgName() {
        return orgName;
    }

    public void setOrgName(String orgName) {
        this.orgName = orgName;
    }

    public static class VmConfig {

        String name;
        String template;
        int networkCount;
        int cpuCount;
        int memSize;
        int diskSize;
        int version;
        String fullName;
        List<String> ipAddress;

        public VmConfig(String name, String template, int cpuCount, int networkCount, int memSize, int diskSize,
                int version) {
            this.name = name;
            this.cpuCount = cpuCount;
            this.networkCount = networkCount;
            this.memSize = memSize;
            this.diskSize = diskSize;
            this.version = version;
            this.template = template;
            this.ipAddress = new ArrayList<String>();
        }

        public String getName() {
            return name;
        }

        public String getTemplate() {
            return template;
        }

        public int getNetworkCount() {
            return networkCount;
        }

        public int getCpuCount() {
            return cpuCount;
        }

        public int getMemSize() {
            return memSize;
        }

        public int getDiskSize() {
            return diskSize;
        }

        public int getVersion() {
            return version;
        }

        public String getFullName() {
            return fullName;
        }

        public void setFullName(String id) {
            int startIndex = id.lastIndexOf(":");
            this.fullName = name + " (" + id.substring(startIndex + 1) + ")";
        }

        public List<String> getIpAddress() {
            return ipAddress;
        }

    }
}
